package Views;

import Source.CreateFlight;
import UCM.UCCreateFlight;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author Joshua King
 */
public class ViewCreateFlight extends JPanel {
    private static String TEXT = "Error!111ewrc";
    private static String TEXT2 = "Success!LKJAS";
    private static int MAXCHAR = 10;
    private JLabel flightDepartureLocLabel = new JLabel("Flight Departure");
    private JLabel flightArrivalLocLabel = new JLabel("Flight Arrival");
    private JLabel flightDepartureDateLabel = new JLabel("Flight Departure Date");
    private JLabel flightArrivalDateLabel = new JLabel("Flight Arrival Date"); 
    private JLabel flightDepartureTimeLabel = new JLabel("Flight Departure Time");
    private JLabel flightArrivalTimeLabel = new JLabel("Flight Arrival Time"); 
    private JLabel flightNoSeatLabel = new JLabel("Seats");     
    private JTextField flightDepartureLocTxt = new JTextField(MAXCHAR);
    private JTextField flightArrivalLocTxt = new JTextField(MAXCHAR);
    private JTextField flightDepartureDateTxt = new JTextField(MAXCHAR);
    private JTextField flightArrivalDateTxt = new JTextField(MAXCHAR);
    private JTextField flightDepartureTimeTxt = new JTextField(MAXCHAR);
    private JTextField flightArrivalTimeTxt = new JTextField(MAXCHAR);
    private JTextField flightNoSeatTxt = new JTextField(MAXCHAR);
    private JButton flightButton = new JButton("Construct Flight");
    private UCCreateFlight UCCreateFlight = new UCCreateFlight(this);
    private CreateFlight model;
    private JLabel flightSuccessLabel = new JLabel();
    
    public ViewCreateFlight() {
        add(flightDepartureLocLabel);
        add(flightDepartureLocTxt);
        add(flightArrivalLocLabel);
        add(flightArrivalLocTxt);
        add(flightDepartureDateLabel);
        add(flightDepartureDateTxt);
        add(flightArrivalDateLabel);
        add(flightArrivalDateTxt);
        add(flightDepartureTimeLabel);
        add(flightDepartureTimeTxt);
        add(flightArrivalTimeLabel);
        add(flightArrivalTimeTxt);
        add(flightNoSeatLabel);
        add(flightNoSeatTxt);
        add(flightButton);
        add(flightSuccessLabel);
        flightButton.addActionListener(new AdapterUCCToAL(UCCreateFlight));
    }

    public void loadData() {
        model.setFlightArrivalLoc(flightArrivalLocTxt.getText());
        model.setFlightArrivalDate(flightArrivalDateTxt.getText());
        model.setFlightArrivalTime(flightArrivalTimeTxt.getText());
        model.setFlightDepartureLoc(flightDepartureLocTxt.getText());
        model.setFlightDepartureDate(flightDepartureDateTxt.getText());
        model.setFlightDepartureTime(flightDepartureTimeTxt.getText());
        model.setFlightNoSeat(flightNoSeatTxt.getText());
    }

    public void loadTo(CreateFlight model) {
        this.model = model;
    }

    public void updateFailure() {
        ViewMain.getInstance().updateMsg(TEXT);
    }

    public void updateSuccess() {
 
        flightDepartureLocTxt.setText("");
        flightArrivalLocTxt.setText("");
        flightDepartureDateTxt.setText("");
        flightArrivalDateTxt.setText("");
        flightDepartureTimeTxt.setText("");
        flightArrivalTimeTxt.setText("");
        flightNoSeatTxt.setText("");
        ViewMain.getInstance().updateMsg(TEXT2);
    }
    
}
